package com.cy.sys.log.controller;

import java.util.Arrays;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.cy.sys.log.Dao.SysconumerRoleDao;
import com.cy.sys.log.page.vo.JSONResult;
import com.cy.sys.log.service.UserSerivce;
import com.cy.sys.pojo.SysUser;

@RestController
@RequestMapping("/role/")
public class sysUsercontorller {
	@Autowired
	private UserSerivce userservice;
	@Autowired
	private SysconumerRoleDao sysunerrole;
	
	@RequestMapping("doFindPageObjects")
	public JSONResult doFindPageObjects(String name,Integer pageCurrent) {
		return new JSONResult(userservice.findAllUserObject(name, pageCurrent));	
	}
	
	@RequestMapping("doSaveObject")
	public JSONResult doSaveObject(SysUser sysuser,Integer[] menuIds) {
		System.out.println(Arrays.toString(menuIds));
		userservice.insertuserRoleObject(sysuser, menuIds);
		return new JSONResult("insert ok"); 	
	}
	
	@RequestMapping("doFindObjectById")
	public JSONResult doFindObjectById(Integer id) {
		//System.out.println(id);
		return new JSONResult(userservice.findRoleById(id)); 	
	}
	@RequestMapping("doUpdateObject")
	public JSONResult doUpdateObject(SysUser sysuser,Integer[] menuIds) {
		System.out.println(Arrays.toString(menuIds));
		userservice.updateObjectById(sysuser, menuIds);
		return new JSONResult("update ok"); 	
	}
	@RequestMapping("doFindRoles")
	public JSONResult doFindRoles() {
		return new JSONResult(sysunerrole.selectdept());
	}
	
}
